<?php
header("content-type:text/html;charset=utf-8");
include "../public/config/config.php";
include("../public/include/pagePid.class.php");
include "../public/include/funcs.php";
include "../public/include/money.class.php";
$obj_xf=new money($cfg_dbhost,$cfg_dbuser,$cfg_dbpwd,$cfg_dbname,$cfg_dbchar);
$obj=new page($cfg_dbhost,$cfg_dbuser,$cfg_dbpwd,$cfg_dbname,$cfg_dbchar);
$type=$_REQUEST['type'];
$keyword=$_REQUEST['keyword'];
$pid=$_REQUEST['pid'];

$where_date=$_REQUEST['where_date'];
$where_int=$obj_xf->date_int($where_date);
echo "按月查询功能开发中...";
//var_dump($where_int);

$arr=$obj->listData("user",10,$type,$keyword,$pid);
$sel_arr[$type]="selected";

$link=conn($cfg_dbhost,$cfg_dbuser,$cfg_dbpwd,$cfg_dbname,$cfg_dbchar);
if($pid=="all"){
	$title_name="所有会员一览表";
}elseif($pid==0){
	$title_name="顶级会员一览表";
}else{
	$self_arr=select($link, "user","id=$pid");
	$name = $self_arr[0]['tname'] ? $self_arr[0]['tname'] : $self_arr[0]['nickname'];
	$title_name=$name." 的子级会员";
}

foreach($arr as $k=>$v){
	$arr[$k]['self_xf']=$obj_xf->self_xf($v['id']);
	$arr[$k]['all_xf']=$obj_xf->all_xf($v['id']);
}
?>
<html>
	<head>
		<meta charset="UTF-8">
		<title><?php echo $title_name;?></title>
		<link rel="stylesheet" type="text/css" href="../public/css/main.css"/>
	</head>
	<body>
<div class="tab">
	<h3><?php echo $title_name;?></h3>
	<form action="index.php" method="post">
		<input type="hidden" name="pid" value="<?php echo $pid;?>" />
		<select name="type">
			<option <?php echo $sel_arr['tname']?> value="tname">姓名</option>
			<option <?php echo $sel_arr['id']?> value="id">编号</option>
			<option <?php echo $sel_arr['uname']?> value="uname">用户名</option>
			<option <?php echo $sel_arr['regtime']?> value="regtime">注册的时间</option>
		</select>
		关键字：<input type="text" name="keyword" value="<?php echo $keyword;?>" />
		按月查询：<input type="text" placeholder="请用类似格式：2019-1" name="where_date" value="<?php echo $where_date;?>" />
		<input type="submit" value="搜索"/> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <a href="nav.html">导航</a>
		<a class="float_r mar_l_20" href="index.php?pid=0">查看顶级会员</a>
		<a class="float_r mar_l_20" href="index.php?pid=all">查看所有会员</a>
		<a target="_blank" class="float_r mar_l_20" href="xiaofei.php?pid=all">查看所有消费</a>
	</form>
	<table border="1" cellspacing="0" cellpadding="0">
		<tr>
			<th>ID号</th>
			<th>真实姓名</th>
			<th>昵称</th>
			<th>总消费(元)</th>
			<th>总业绩（元）</th>
			<th>注册时间</th>
			<th>操作</th>
		</tr>
<?php
foreach($arr as $v){
?>			
		<tr>
			<td><?php echo $v['id'];?></td>
			<td><?php echo $v['tname'];?></td>
			<td><?php echo $v['nickname'];?></td>
			<td><?php echo $v['self_xf'];?> &nbsp;&nbsp;&nbsp;<a target="_blank" href="showOne.php?id=<?php echo $v['id'];?>">查看详情</a></td>
			<td><?php echo $v['all_xf'];?> &nbsp;&nbsp;&nbsp;<a target="_blank" href="yeji.php?id=<?php echo $v['id'];?>">查看详情</a></td>
			<td><?php echo $v['c_time'];?></td>
			<td>
				<a target="_blank" href="see_top.php?id=<?php echo $v['id'];?>">查看上级</a>
				<a target="_blank" href="index.php?pid=<?php echo $v['id'];?>">查看下级</a>
				<a target="_blank" href="see_tree.php?id=<?php echo $v['id'];?>">查看子集结构</a>
				<a target="_blank" href="add_child.php?id=<?php echo $v['id'];?>">添加下级</a>
			</td>
		</tr>
<?php
}
?>
		<tr>
			<td colspan="10">
				<?php echo $obj->showPage();?>
			</td>
		</tr>		
	</table>
</div>
	</body>
</html>